package cn.bugstack.mybatis.datasource.druid;

import java.util.Properties;

import javax.sql.DataSource;

import com.alibaba.druid.pool.DruidDataSource;

import cn.bugstack.mybatis.datasource.DataSourceFactory;

/**
 * description: 具体druid数据源工厂
 * taskId：
 * <pre>
 * change history:
 * date             defect#             person                comments
 * ---------------------------------------------------------------------
 * 2024/11/27       ********         zhaochaoyue        create file
 * </pre>
 *
 * @author: zhaochaoyue
 * @date: 2024/11/27 16:08
 * @copyright: 2024
 */
public class DruidDataSourceFactory implements DataSourceFactory {
    
    private Properties properties;
    
    @Override
    public void setProperties(Properties properties) {
        this.properties =properties;
    }

    @Override
    public DataSource getDataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(properties.getProperty("driver"));
        dataSource.setUrl(properties.getProperty("url"));
        dataSource.setUsername(properties.getProperty("username"));
        dataSource.setPassword(properties.getProperty("password"));
        return dataSource;
    }
}
